// pages/operat/activityManager/activityManager.js
const LApp = getApp();

import __global from "../../../source/js/global.js"


Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageIndex: 1,
    pageSize: 10,
    searchKey: "",
    activityList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (!LApp.globalData.userInfo) {
      wx.navigateTo({
        url: '../../my/logon/logon',
      })
    }
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.setData({
      activityList: new Array()
    })
    this.getactivityList();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    this.setData({
      open: -1
    })
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  },
  activitydetail: function (e) {
    this.activityModel = e.currentTarget.dataset.activitymodel;
    if (this.activityModel) {
      LApp.pages.add(this);
      wx.navigateTo({
        url: 'activityDetail/activityDetail?isDetail=false',
      })
    }
  },
  activitySearch: function (e) {
    this.setData({
      searchKey: e.detail.value
    })
    this.data.activityList = new Array();
    this.getactivityList();
  },
  getactivityList: function (pageindex) {
    this.setData({
      pageIndex: pageindex || 1
    })
    var _this = this;
    LApp._get({
      url: "nbapi/actity/list",
      data: { pageIndex: this.data.pageIndex, pageSize: this.data.pageSize, Asearch: this.data.searchKey },
      success: function (r) {

        _this.setData({
          activityList: _this.data.activityList.appendArray(r)
        })
      }
    })
  },
  touchMove: __global.Tap_Dray,
  tap_end: __global.Tap_End,
  bindEditDetailClick:function () {
    wx.showToast({
      icon: 'none',
      title: '攻城狮正在攻城中，稍等~',
    })
  }

})